<?php
	@include('../include/global.php');

	if(!$user) {
		$user = new user();
		if(isset($_SESSION['user'])) {
			$user = unserialize($_SESSION['user']);
		}
	}
	if($user->isLogged()) {
		echo '<img src="static/images/icons/user.png" /> <b>Gestione profilo</b>';
	?>
		<ul>		    <li>		        <a href="?p=editPersonalData">Modifica dati personali</a>		    </li>
			<li>
		        <a href="?p=editAddress">Modifica indirizzi</a>
		    </li>
			<li>
		        <a href="?p=newAddress">Aggiungi nuovo indirizzo</a>
		    </li>
		    <li>
		        <a href="?p=orderStatus">Visualizza stato ordini</a>
		    </li>
		    <li>
		        <a href="?p=viewBonus">Visualizza bonus</a>
		    </li>
		</ul>
		
		<?php	
		if($user->status > 1) {
			echo '<img src="static/images/icons/admin.png" /> <b>Gestione admin</b>';
			echo ' [ Livello: '.$user->level.' ]';
		?>
		<ul>
			<?php 
				if($user->status > 1) {
			?>
				<li>
		        	<a href="?p=viewOrders">Visualizza ordini</a>
		    	</li>
			<?php 
				}
				
				if($user->level == 2 || $user->level == 4) {
			?>
				<li>
			        <a href="?p=editIngredient">Mostra ingradienti</a>
			    </li>
			    <li>
			        <a href="?p=newIngredient">Aggiungi nuovo ingrediente</a>
			    </li>
			    <li>
			        <a href="?p=newProduct">Aggiungi nuovo prodotto</a>
			    </li>
			<?php 
				}
				if($user->level == 4) {
			?>
				<li>
			        <a href="?p=userManagement">Gestione dipendenti</a>
			    </li>
			<?php 
				}
			?>
		</ul>
<?php
		}	}	echo'<img src="static/images/icons/cart.png" /> <b>Carrello</b>';		$basket = new basket();		if($basket->getCountProducts() == 0) {			echo '<br /><br />';			echo '<i>Il carrello &egrave; vuoto!</i>';			echo '<br />';		} else {			echo '<table id="side_basket">';				echo '<tr>';					echo '<th>Qta.</th>';					echo '<th>Nome</th>';
					echo '<th>Totale</th>';
				echo '</tr>';							$products = $basket->getProducts();				foreach($products as $product) {					echo '<tr>';						echo '<td>';							echo $product['quantity'];						echo '</td>';						echo '<td>';							echo $product['name'];						echo '</td>';
						echo '<td>';
							echo formatPrice($product['price']*$product['quantity']);
						echo '</td>';					echo '</tr>';				}			echo '</table>';		}?>	
	<ul>
		<li><a href="index.php?p=basket">Mostra carrello</a></li>
		<li><a href="index.php?p=clearBasket">Svuota carrello</a></li>
	</ul>